/*
 * ProducerConsumerShared.h
 *
 *  Created on: Feb 9, 2010
 *      Author: Jamie LaPointe
 */

#ifndef PRODUCERCONSUMERSHARED_H_
#define PRODUCERCONSUMERSHARED_H_

#include <vector>
#include <pthread.h>
#include "Request.h"

namespace ProducerConsumer
{

namespace Common
{

class ProducerConsumerShared
{
public:
   std::vector<Request> requestList;
   pthread_mutex_t mutex;
   pthread_cond_t producerCond;
   pthread_cond_t consumerCond;

   ProducerConsumerShared()
   {
      //
      // init mutex and condition variables
      //
      pthread_mutex_init(&mutex, 0);
      pthread_cond_init(&consumerCond, 0);
      pthread_cond_init(&producerCond, 0);
   }

   ~ProducerConsumerShared()
   {
      pthread_mutex_destroy(&mutex);
      pthread_cond_destroy(&consumerCond);
      pthread_cond_destroy(&producerCond);
   }

private:
   // disallow copying and the equal operator
   ProducerConsumerShared(const ProducerConsumerShared& rhs);
   ProducerConsumerShared& operator=(const ProducerConsumerShared&);
};

} // namespace Common

} // namespace ProducerConsumer

#endif /* PRODUCERCONSUMERSHARED_H_ */
